package dormouse.vfs.ui;

/**
 * This class serves as an adapter to insure that files in a tree can be selected.
 * @author Mark Fortner
 * @version 1.0
 */

import java.io.File;

import org.apache.commons.vfs2.FileObject;
import org.apache.commons.vfs2.FileSystemException;
import org.apache.commons.vfs2.VFS;

public class SelectableFile  {


    /**
     * Constructor
     * @param file
     */
    public SelectableFile(FileObject file) {
        this.file = file;
    }

    /**
     * Constructor
     * @param file
     */
    public SelectableFile(File file) {
        try {
			this.file = VFS.getManager().toFileObject(file);
		} catch (FileSystemException e) {
			e.printStackTrace();
		}
    }

    /**
     * This method outputs the file information plus the "selected" flag.
     * @return
     */
    public String toString() {
        return file.toString() + " selected: " + selected;
    }

    /**
     * This method sets the selected flag
     * @param selected
     */
    public void setSelected(boolean _selected) {
        selected = _selected;
    }

    /**
     * This method determines if the file is selected.
     * @return
     */
    public boolean isSelected() {
        return selected;
    }

    /**
     * This method gets the file.
     * @return
     */
    public FileObject getFile() {
        return file;
    }

    private FileObject file;
    private boolean selected = false;
}